<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<input type="text" id="textMsg" value="请八十号顾客，取餐">
<button onclick="speak()">播放</button>
<button onclick="pause()">暂停</button>

<script>
    var speech = new SpeechSynthesisUtterance();


    // 播放
    function speak() {

        speech.text = textMsg.value // 获取并设置说话时的文本
        speechSynthesis.speak(speech);
    }

    // 暂停
    function pause() {
        speechSynthesis.pause()
    }

</script>
</body>

</html>